package com.syaccp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syaccp.mapper.ExchargePackageMapper;
import com.syaccp.model.ExchargePackage;
import com.syaccp.service.ExchargePackageService;
import org.springframework.stereotype.Service;

@Service
public class ExchargePackageServiceImpl extends ServiceImpl<ExchargePackageMapper, ExchargePackage> implements ExchargePackageService {


    /**
     * 通过充值金额寻找对应充值包
     * @param money
     * @return
     */
    @Override
    public ExchargePackage findPackageByMoney(Double money) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("status",0);
        queryWrapper.le("excharge_money",money);
        queryWrapper.last("order by excharge_money desc limit 1");

        return this.baseMapper.selectOne(queryWrapper);
    }
}
